﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using MODEL;
using BLL;

namespace UI.Controllers
{
    public class ValuesController : ApiController
    {
        // GET api/values
        public IEnumerable<string> Get()
        {
            return new string[] { "value1", "value2" };
        }
        [HttpPost]
        [ActionName("regist")]
        public int regist(uinfor u)
        {
            return ubll.getbll().regist(u);
        }
        [HttpGet]
        [ActionName("isregist")]
        public int isregist(string uname)
        {
            return ubll.getbll().isregist(uname);
        }
        [HttpGet]
        [ActionName("login")]
        public int login(string uname, string upwd)
        {
            return ubll.getbll().login(uname, upwd);
        }
        [HttpGet]
        [ActionName("selrole")]
        public string selrole(string uname)
        {
            return ubll.getbll().selrole(uname);
        }
        [HttpGet]
        [ActionName("showquanxian")]
        public List<uinfor> showquanxian(string rname)
        {
            return ubll.getbll().showquanxian(rname);
        }
        // GET api/values/5
        public string Get(int id)
        {
            return "value";
        }
        // POST api/values
        public void Post([FromBody]string value)
        {
        }
        /// <summary>
        /// 显示医院信息表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [ActionName("showhospital")]

        public List<uinfor> showDoctor()
        {
            ubll bll = ubll.getbll();

            var result = bll.showDoctor();
            return result.ToList();
        }
        /// <summary>
        /// 显示挂号记录表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [ActionName("showRecord")]
        
        public List<uinfor> show()
        {
            ubll bll = ubll.getbll();

            var result = bll.show();
            return result.ToList();
        }
        /// <summary>
        /// 添加挂号记录表
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        [ActionName("addRecord")]
        
        // POST api/values
        public int Post(uinfor model)
        {
            ubll bll = ubll.getbll();

            var result = bll.ADDregister(model);
            return result;
        }

        // PUT api/values/5
        public void Put(int id, [FromBody]string value)
        {
        }
        [HttpPut]
        [ActionName("updRecord")]
        public int Put(uinfor u)
        {
            ubll bll = ubll.getbll();
            var result = bll.UPDregister(u);
            return result;
        }
        // DELETE api/values/5
        public void Delete(int id)
        {
        }
        /// <summary>
        /// 删除挂号记录表
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete]
        [ActionName("delRecord")]
        public int Del(int id)
        {
            ubll bll = ubll.getbll();

            var result = bll.DELETEregister(id);
            return result;
        }
        [HttpGet]
        [ActionName("Showurealation")]
        /// <summary>
        /// 用户与专家交流显示
        /// </summary>
        /// <returns></returns>
        public List<uinfor> Showurealation()
        {
            return ubll.getbll().Showurealation();
        }
        [HttpPost]
        [ActionName("Addurealation")]
        /// <summary>
        /// 用户专家关系表添加
        /// </summary>
        /// <returns></returns>
        public int Addurealation(uinfor add)
        {
            return ubll.getbll().Addurealation(add);
        }
        [ActionName("chaxun")]
        [HttpGet]
        /// <summary>
        /// 查询科室专家
        /// </summary>
        /// <param name="zid"></param>
        /// <returns></returns>
        public List<uinfor> chaxunkeshi(int zid)
        {
            return ubll.getbll().chaxunkeshi(zid);
        }
        [ActionName("typelist")]
        [HttpGet]
        /// <summary>
        /// 二级联动
        /// </summary>
        /// <param name="zid"></param>
        /// <returns></returns>
        public List<uinfor> typelist(int zid)
        {
            return ubll.getbll().typelist(zid);
        }
    }
}